<template>
    <div>
        <comA></comA>
        <button @click="sendData()">发送数据</button>
        <button>{{computFun}}</button>
        <input v-model="input" type="text" v-focus>
        <hr>
        <div>{{filtersText | filtersTextChange}}</div>
        <button @click="seeData()">查看数据</button>
        <button @click="changeUid()">改变uid</button>
    </div>
</template>
<script>
import comA from "@/components/comA";
import { EventBus } from "@/assets/js/eventBus.js";
export default {
  data() {
    return {
      msg: "这是home",
      tip: "evenBus",
      input: "",
      type:'success',
      text:'按钮',
      filtersText: '1',
    };
  },
  filters: {
    filtersTextChange: function (dataStr) {
      let a= 3 + dataStr
      return(a);
    }
  },
  provide() {
    return {
      for: this.msg
    };
  },
  components: {
    comA,

  },
  methods: {
    sendData() {
      EventBus.$emit("addition", {
        tip: this.tip
      });
    },
    seeData(){
      console.log(this.$data)
    },
    //改变vuex中的uid
    changeUid(){
      this.$store.mutations;
      this.$store.commit('changeUid',10);//使用mutations
      console.log(this.$store.state.user.uid);
    }
  },
  computed: {
    computFun() {
      console.log(this.msg);
      return this.msg;
    }
  },
  watch: {
    input(now, old) {
      console.log(now);
      console.log(old);
    }
  },
  mounted(){
    var uid = this.$store.state.user.uid;//获取vuex
    console.log(uid);
  }
};
</script>
<style lang="less" scoped>
</style>
